package com.dzzw.Servlet.LeaderServlet;

import com.dzzw.Dao.LeaderDao;
import com.dzzw.Model.Leader;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/View/LeaderModifyServlet")
public class LeaderModifyServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    LeaderDao leaderDao = new LeaderDao();
    public LeaderModifyServlet(){
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int leader_id = Integer.parseInt(request.getParameter("leader_id"));
        String leader_name = request.getParameter("leader_name");
        String leader_password = request.getParameter("leader_password");
        String leader_actnumber = request.getParameter("leader_actnumber");
        Leader leader = new Leader();
        leader.setLeader_id(leader_id);
        leader.setLeader_actnumber(leader_name);
        leader.setLeader_password(leader_password);
        leader.setLeader_name(leader_actnumber);
        leaderDao.LeaderModify(leader);
        System.out.println("部门领导修改成功！");
        response.sendRedirect("/View/Leader.jsp");
    }
}
